﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUS;
using TuyenDungViecLam.CommonResource;

namespace TuyenDungViecLam.Admin
{
    public partial class ChitTietTinSaiPham : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LienKetDuLieu();
            }
        }

        public void LienKetDuLieu()
        {
            string Mcv = Request.QueryString["Mcv"];
            try
            {
                var CTCongViec = ChiTietCongViec_BUS.ChiTietCongViecSaiPham(Mcv);
                RPNhaTuyenDung.DataSource = NhaTuyenDung_BUS.MoTaCongTyTheoCongViec(Mcv);
                RPNhaTuyenDung.DataBind();
                RPCongViec.DataSource = CTCongViec;
                RPCongViec.DataBind();
                int n = RPCongViec.Items.Count;
                BulletedList listng = (BulletedList)RPCongViec.Items[0].FindControl("blnganhnghe");
                listng.DataSource = NganhNghe_BUS.LayNganhNgheTheoCongViec(Mcv);
                listng.DataTextField = "TenNganh";
                listng.DataBind();
                lbsolanxem.Text = (CTCongViec[0].SoLuotXem + 1).ToString();
                lbngayhethang.Text = CTCongViec[0].NgayHetHanDang.ToString();
                ChiTietCongViec_BUS.CapNhatSoLuotXem(CTCongViec[0].SoLuotXem + 1, Mcv);

            }
            catch (Exception)
            {
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }

        protected void BtNopCVUpload_Click(object sender, EventArgs e)
        {
            ChiTietCongViec_BUS.ChoPhepDangLaiTin(Request.QueryString["Mcv"]);
            Alert.ShowAndRedirect("Đã cho phép đăng lại tin !", "CacTinSaiPham.aspx");
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            ChiTietCongViec_BUS.HuyCongViec(Request.QueryString["Mcv"]);
            Alert.ShowAndRedirect("Đã không cho đăng tin này !", "CacTinSaiPham.aspx");
        }
    }
}
